<include file="Public/header" />
<include file="Public/menu" />
<style>
    .edit-list{
        display:none;
        width: 78px;position:absolute;top:-1px;left:78px;background:white; border: 1px solid #666
    }
    .edit-list.active{
        display:block;
        border-color: #666666;
        color: #3367AC;
        z-index: 999;
        margin-top: 1px;
        padding-right: 5px;

    }
    .order-edit{
        padding-left:0;
        margin: 3px 0;
    }
    .order-edit li{
        list-style-type:none;
        cursor: pointer;
        padding: 0 4px;
        float: none;
        width: auto;
        text-align: right;
        font-size: 12px;
        line-height: 23px;
        height: 23px;
    }
    .order-edit li a{


        font-size: 12px;
    }
    .cur{
      border-bottom: 1px #cccccc dotted;
        padding-bottom: 3px;
    }
    .handle-order{
        width: 79px;
    }
    .handle-order.active{
        background:white;

        border: 1px #666666 solid;
        border-right: 0 none;
        padding: 2px 8px 2px 4px;
        font-size: 13px;
        z-index: 10000;
        color: #3367ac;
    }

    .handle-order.active b{
        background: url('/Public/images/arrow-right.gif') no-repeat scroll 50% 50%;
        display: inline-block;
        width: 10px;
        height: 10px;
        vertical-align: center;

    }
    .handle-order b {
        background: url('/Public/images/arrow-down.gif') no-repeat scroll 50% 50%;
        display: inline-block;
        width: 10px;
        height: 10px;
        margin-left: 4px;
        vertical-align: center;
    }


</style>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            店铺订单
            <small>全国送会员订单列表</small>
        </h1>

    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="row"><div class="col-md-12"><div class="nav-tabs-custom">
            <div class="tab-content">
                <div class="box-header">
                    <h3 class="box-title"></h3>
                    <div class="form-inline pull-right">
                        <form  id="search_form" name="search_form" action=""  method="get" >
                            <fieldset>
                                <select class="form-control" id="sort" name="sort" style="width: auto">
                                    <option value="">--请选择--</option>
                                    <option value="payTimeDesc" {$view['sort'] == 'payTimeDesc' ? 'selected' : ''}>按支付日期降序</option>
                                    <option value="payTimeAsc" {$view['sort'] == 'payTimeAsc' ? 'selected' : ''}>按支付日期升序</option>
                                    <option value="shouHuoTimeDesc" {$view['sort'] == 'shouHuoTimeDesc' ? 'selected' : ''}>按收货日期降序</option>
                                    <option value="shouHuoTimeAsc" {$view['sort'] == 'shouHuoTimeAsc' ? 'selected' : ''}>按收货日期升序</option>
                                    <option value="moneyDesc" {$view['sort'] == 'moneyDesc' ? 'selected' : ''}>按支付金额大</option>
                                    <option value="moneyAsc" {$view['sort'] == 'moneyAsc' ? 'selected' : ''}>按支付金额小</option>
                                </select>
                                <div class="input-group input-group-sm">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-primary" onclick="searchClick('{:U('QgsOrders/orderList')}')">排序</button>
                                    </div>
                                </div>
                                &nbsp;&nbsp;
                                <select class="form-control" id="search" name="search" style="height:30px; font-size:12px;">
                                    <option value="">--请选择--</option>
                                    <option value="order_id" {$view['search'] == 'order_id' ? 'selected' : ''}>订单号</option>
                                    <option value="member_id" {$view['search'] == 'member_id' ? 'selected' : ''}>会员ID</option>
                                </select>
                                <div class="input-group input-group-sm">
                                    <div class="input-group input-group-sm">
                                        <input type="text" class="form-control" id="search_val"  placeholder="搜索" name="search_val" value="{$view['searchVal']}">
                                    </div>
                                </div>
                                <div class="input-group input-group-sm">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-primary" onclick="searchClick('{:U('QgsOrders/orderList')}')"><i class="fa fa-search"></i></button>
                                    </div>
                                </div>
                            </fieldset>
                        </form>
                    </div>
                </div>
                    <div class="tab-pane active" id="tab_0">
                    <div class="box">
                        <!-- /.box-header -->
                        <div class="box-body table-responsive no-padding">

                            <table class="table table-hover table-view-list" style="overflow-x:scroll;">
                                <thead>
                                <tr>
                                    <td colspan="10" style="color: #FF0000">确认佣金：不排除手续费</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <th>序</th>
                                    <th>订单号</th>
                                    <th>支付日期</th>
                                    <th>支付订单金额</th>
                                    <th>确认收货日期</th>
                                    <th>预估佣金</th>
                                    <th>确认金额</th>
                                    <th>确认佣金</th>
                                    <th>购买人会员ID</th>
                                    <th>结算状态</th>
                                </tr>
                                <foreach  name="orders" item="order" key="index">
                                    <tr>
                                        <td>{$index+1}</td>
                                        <td><a href="{:U('QgsOrders/orderDetail',['id'=>$order[order_id]])}">{$order.order_id}</a></td>
                                        <td><empty name="order.time"><else/>{$order.time|date="Y-m-d", ###}</empty></td>
                                        <td>{$order.money}</td>
                                        <td><empty name="order.received_time"><else/>{$order.received_time|date="Y-m-d",###}</empty></td>
                                        <td>{$order.qgsFee}</td>
                                        <td>{$order.last_money}</td>
                                        <td>{$order.last_cy_fee}</td>
                                        <td>{$order.nickname}</td>
                                        <td>{$order.jsType}</td>
                                    </tr>
                                </foreach >
                                </tbody></table>
                        </div>
                        <div class="box-footer clearfix">

                            <a class="btn btn-sm btn-primary grid-refresh" style="float: right" onclick="javascript:location.replace(location.href);"><i class="fa fa-refresh"></i></a>
                            {$page}


                        </div>
                        <!-- /.box-body -->
                    </div>
                </div>
            </div>
        </div></div></div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer" />
<script src="/Public/admin/jedate/jedate.js"></script>
<link rel="stylesheet" href="/Public/admin/jedate/jedate.css" />
<script>
    !function(){
        $('.suggest').on('click', function(){

            var dataId = $(this).data('id');

            layer.ready(function(){
                layer.open({
                    type: 2,
                    title: '订单管理',
                    fix: false,
                    maxmin: true,
                    shadeClose: true,
                    area: ['1000px', '750px'],
                    content: dataId,
                    end: function(){
                        layer.tips('Hi', '#about', {tips: 1})
                    }
                });
            });
        });
    }();

</script>
<script data-exec-on-popstate>
    $(function () {
        $("#search_form").validate({
            rules: {
                search_val:{
                    required: true,
                    maxlength: 140,
                },
            },
            messages:{
                search_val:{
                    required: "搜索内容不能为空",
                    maxlength: "搜索内容不能超过140个字符"
                }
            },
            submitHandler: function(form){
                form.submit();   //提交表单
            }
        });

        $('.btn-pei').on('click', function(){
            var dataId = $(this).data('id');

            layer.ready(function(){
                layer.open({
                    type: 2,
                    title: '打印订单',
                    fix: false,
                    maxmin: true,
                    shadeClose: true,
                    area: ['1200px', '730px'],
                    content: dataId,
                    end: function(){
                        layer.tips('Hi', '#about', {tips: 1})
                    }
                });
            });
        });

        $('.btn-kd').on('click', function(){
            var dataId = $(this).data('id');

            layer.ready(function(){
                layer.open({
                    type: 2,
                    title: '打印快递单',
                    fix: false,
                    maxmin: true,
                    shadeClose: true,
                    area: ['1200px', '730px'],
                    content: dataId,
                    end: function(){
                        layer.tips('Hi', '#about', {tips: 1})
                    }
                });
            });
        });


        $('.grid-select-all').change(function() {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.batch-delete').on('click', function() {
            var selected = [];
            $('.grid-item:checked').each(function(){
                selected.push($(this).data('id'));
            });

            if (selected.length == 0) {
                return;
            }

            if(confirm("Are you sure to delete this item ?")) {
                $.post('/admin/auth/roles/' + selected.join(), {_method:'delete','_token':'ALpaP7hXZ6s2dnAdE02Z6mUSHPt8RkYbcDRp6rpw'}, function(data){
                    $.pjax.reload('#pjax-container');
                    noty({
                        text: "<strong>Succeeded!</strong>",
                        type:'success',
                        timeout: 1000
                    });
                });
            }
        });
        $('.handle-order').hover(function(){
            $(this).addClass('active');
            $(this).parent().find('.edit-list').addClass('active');



        },function(){
            $(this).removeClass('active');
            $(this).parent().find('.edit-list').removeClass('active');
        })


    });

    $('.edit-list').hover(function(){
        $(this).addClass('active');
        $(this).parent().find('.handle-order').addClass('active');
    },function(){
        $(this).removeClass('active');
        $(this).parent().find('.handle-order').removeClass('active');
     }

    );

    function isSureGet(order) {
        if(confirm("确认用户已经收到货吗？"))
        {
            $.ajax({
                url:"{:U('orders/finishOrder')}",
                type:'post',
                data:{'order_id':order},
                dataType:'json',
                success:function (data) {
                    if(data.status ==0){
                        alert(data.msg);
                        return false;
                    }else{
                        alert(data.msg);
                        location.reload();
                    }

                },
                error:function (err) {
                    alert('参数错误');
                }

            })

        }
    }
    function ept() {
        $('#eid').submit();
    }

    function searchClick(Url) {
        var sort = $("#sort").val(),
            search = $("#search").val(),
            searchVal = $("#search_val").val(),
            paramStr = '';
        if (sort.length > 0){
            paramStr = '?sort='+sort;
        }
        if (search.length > 0  && (searchVal.replace(/\ +/g,"")).length > 0){
            paramStr = (paramStr.length > 0 ? paramStr+'&search='+search+"&search_val="+encodeURIComponent(searchVal) : '?search='+search+'&search_val='+searchVal);
        }
        window.location.href = Url+paramStr;
    }
</script>
<script src="/Public/layer/layer.js"></script>
